package com.ellen.mac.chatdemo.adpter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ellen.mac.chatdemo.R;
import com.ellen.mac.chatdemo.model.DataPhotoBean;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * Created by aven on 17-12-22.
 */

public class ImageAdapter extends BaseQuickAdapter<DataPhotoBean, BaseViewHolder> {
    private Context context;
    private final int ITEM_LEFT_TEXT = 101;
    private final int ITEM_RIGHT_TEXT = 201;



    public ImageAdapter(int layoutResId, List data, Context context) {
        super(layoutResId, data);
        this.context = context;
    }


    @Override
    protected void convert(BaseViewHolder helper, DataPhotoBean file) {
        ImageView imageView = helper.getView(R.id.item_image);
        Picasso.with(imageView.getContext())
                .load(file.getUrl())
                .centerCrop()
                .resize(file.getWidth(), file.getHeight())
                .into(imageView);
    }
    public void resetRecycledViewPoolSize(RecyclerView recyclerView) {
        recyclerView.getRecycledViewPool().setMaxRecycledViews(ITEM_LEFT_TEXT, 25);
        recyclerView.getRecycledViewPool().setMaxRecycledViews(ITEM_RIGHT_TEXT, 25);
    }

}
